//==============================================================================
#ifndef _LISTBOX_H_
#define _LISTBOX_H_

#pragma once
#include "Component.h"
#include "list"
#include "string.h"
#include "TextBox.h"
#include "vector"
#include <iostream>

typedef std::list<std::string> LISTSTR;
typedef std::vector<ui::TextBox*>	VECTBOX;
struct  Selector {
	LISTSTR::iterator opcionActual;
	int numCaj;
};
//==============================================================================
namespace ui
{
class ListBox : public Component
{
private:
	//Vector of showed boxes.
	VECTBOX* boxes;
	int cantCajas;
	//List of strings/options saved.
	LISTSTR* opciones;
	//First selector points to the first element showed in the listbox.
	Selector selectorPrimero;
	//Last selector points to the Last element showed in the listbox.
	Selector selectorUltimo;
	//Current selector points to the current element selected in the listbox.
	Selector selectorActual;


public:
	ListBox(int posX, int posY, int width, int height, COMPONENT_TYPE type, string name);
	ListBox( int showOpts, int x, int y, int w, int h, LISTSTR* optNames);
	ListBox( int showOpts, int x, int y, int w, int h);
	/**
	Adds the string received to the list.
	**/
	void addOption(std::string newOpt);

	/**
	Deletes the selected option
	**/
	std::string deleteOption();

	/**
	Returns the selected option
	**/
	std::string getSelected();

	/**
	Handles events, mainly regarding box selected.
	**/
	COMPONENT_TYPE handleEvent(SDL_Event* event);
	/**
	Scrolls the listbox downwards.
	**/
	void scrollDown(void);
	/**
	Scrolls the listbox upwards.
	**/
	void scrollUp(void);

	/**
	Draws the listbox.
	**/
	void draw(SDL_Surface*) throw (SDL_Exception);

	~ListBox(void);

	string getType(void);

	static const string LISTBOX_TYPE;

	bool findScene(std::string s);

    bool isEmpty();

private:
	void updateBoxes();
};
};

#endif
//==============================================================================